package hu.genius.view;

import hu.genius.R;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MenuListActivity extends ListActivity {
	private String[] categoryNames;

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Intent intent = new Intent(MenuListActivity.this, ProductsListActivity.class);
		intent.putExtra("category_name", categoryNames[position]);
		intent.putExtra("products_label", getString(R.string.products_label));

		switch (position) {
		case 0:
			intent = new Intent(MenuListActivity.this, PizzaMenuListActivity.class);
			break;
		case 1:
			intent = new Intent(MenuListActivity.this, MainCourseMenuListActivity.class);
			break;
		case 2:
			intent.putExtra("category_id", 6);
			break;
		case 3:
			intent.putExtra("category_id", 2);
			break;
		case 4:
			intent.putExtra("category_id", 10);
			break;
		case 5:
			intent.putExtra("category_id", 4);
			break;
		case 6:
			intent.putExtra("category_id", 3);
			break;
		case 7:
			intent.putExtra("category_id", 9);
			break;
		case 8:
			intent.putExtra("category_id", 11);
			break;
		}
		MenuListActivity.this.startActivity(intent);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menulist_layout);
		categoryNames = new String[] { getString(R.string.pizzas_text),
				getString(R.string.main_course_label),
				getString(R.string.pasta_text),
				getString(R.string.salads_text),
				getString(R.string.desserts_text),
				getString(R.string.soups_text),
				getString(R.string.dressings_text),
				getString(R.string.pickles_text),
				getString(R.string.drinks_text) };

		this.setListAdapter(new ArrayAdapter<String>(this,
				R.layout.list_black_text, R.id.list_content, categoryNames));
	}

	public void back(View view) {
		this.finish();
	}

}
